<?php 
// Set flag that this is a parent file
define( '_JEXEC', 1 );

define('JPATH_BASE', dirname(__FILE__) );

define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();

$vendor_id = (int)$_REQUEST['vendor_id'];
if ($vendor_id == 0) {
    require_once JPATH_BASE. '/administrator/components/com_virtuemart/classes/ps_database.php';
    require_once JPATH_BASE. '/administrator/components/com_virtuemart/classes/ps_user.php';
    $ps_user = new ps_user;
    $user =& JFactory::getUser();
    $vendor_id = $ps_user->getUserInfomations($user->get('id'))->record[0]->vendor_id;
}

$type = $_REQUEST['typeexport'];
if ($type == 'checkdata') {
    require_once ( JPATH_BASE. '/administrator/components/com_virtuemart/classes/ps_exportdata.php');
    
    $row_count = ps_exportdata::checkExport($vendor_id);
    echo $row_count;
} else if ($type == 'cleardata') {
    require_once ( JPATH_BASE. '/administrator/components/com_virtuemart/classes/ps_cleardata.php');
    
    ps_cleardata::processClear($vendor_id);
} else {
    require_once ( JPATH_BASE. '/administrator/components/com_virtuemart/classes/ps_exportdata.php');
    
    ps_exportdata::processExport($vendor_id);
}

?>